package exercises.interfaces;

interface Cycle { void ride(); }

interface CycleFactory { Cycle getCycle(); }

class Unicycle implements Cycle {
    Unicycle() {}
    @Override
    public void ride() {System.out.println("unicycle ride");}
}

class UnicycleFactory implements CycleFactory {
    public Cycle getCycle() {
        return new Unicycle();
    }
}

class Bicycle implements Cycle {
    Bicycle() {}
    public void ride() {System.out.println("bicycle ride");}
}

class BicycleFactory implements CycleFactory {
    public Cycle getCycle() {
        return new Bicycle();
    }
}

class Tricycle implements Cycle {
    Tricycle() {}
    public void ride() {System.out.println("tricycle rie");}
}

class TricycleFactory implements CycleFactory {
    public Cycle getCycle() {
        return new Tricycle();
    }
}

public class Cycles {
    public static void CycleConsumer(CycleFactory fact) {
        Cycle c = fact.getCycle();
        c.ride();
    }
    public static void main(String[] args) {
        CycleConsumer(new UnicycleFactory());
        CycleConsumer(new BicycleFactory());
        CycleConsumer(new TricycleFactory());
    }
}
